package cn.shadow.module.chess.message.chnChess.frame;

import cn.shadow.GameClient;
import cn.shadow.frame.game.MyGame;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class ChnChessGame extends MyGame {
    static ChnChessGame chessGame;
    private ChnChessScreen chessScreen;
    private ApplicationContext context;

    @Override
    public void create() {
        context = new AnnotationConfigApplicationContext(GameClient.class);
        ChnChessGame bean = context.getBean(ChnChessGame.class);
        System.out.println(bean==this);
        this.chessScreen = new ChnChessScreen(this);
        setScreen(chessScreen);
        chessGame=this;
    }

    @Override
    public void dispose() {
        super.dispose();
        if (chessScreen != null) {
            chessScreen.dispose();
            chessScreen = null;
        }
    }

    public ChnChessScreen getChessScreen() {
        return chessScreen;
    }

    public void setChessScreen(ChnChessScreen chessScreen) {
        this.chessScreen = chessScreen;
    }

    public ApplicationContext getContext() {
        return context;
    }

    public void setContext(ApplicationContext context) {
        this.context = context;
    }

    public static ChnChessGame me(){
        return chessGame;
    }

}
